package com.order.controller.front_end;

import com.order.dao.Desk;
import com.order.dao.Dish;
import com.order.dao.DishType;
import com.order.service.DeskService;
import com.order.service.DishService;
import com.order.service.DishTypeservice;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Scope("prototype")
@AllArgsConstructor
public class WebStartController {

    private DeskService deskService;
    private DishTypeservice dishTypeservice;
    private DishService dishService;

    @RequestMapping("/web")
    public String webStart(){
        log.info("操作成功");
        return "正在进入天上人间......";
    }


    @ResponseBody
    @RequestMapping("/start")
    public List<Desk>  getDesk(Desk desk){
        List<Desk> deskList = deskService.getDesks(desk);
        log.info("查询成功");
        return deskList;
    }


    @ResponseBody
    @RequestMapping("/menu")
    public String  Menus(DishType dishType){
        List<DishType> dishTypes = dishTypeservice.selectDishType(dishType);
            log.info("响应成功");
            return dishTypes+" ";
    }


    @ResponseBody
    @RequestMapping("/menu/dishes/{type_id}")
    public String OrderDish(@PathVariable("type_id")int type_id, Dish dish){
        List<Dish> dishes = dishService.dishSelect(dish);
        log.info("响应成功");
        return dishes+" ";
    }

}
